from jiekou.port_job.mall.interface.Interface import Memberlnterface
from jiekou.port_job.mall.utils.sendmethod import SendMethod


class AddressInrerface:
    def __init__(self,url,headers):
        self.url = url
        self.headers = headers

    def address(self,payload):
        method = 'post'
        url = self.url + '/member/address/add'
        return SendMethod.send_method(method=method, url=url, headers=self.headers, json=payload)

    def get_ress(self,payload):
        method = 'get'
        url = self.url + f'/member/address/{payload}'
        return SendMethod.send_method(method=method, url=url, headers=self.headers)

if __name__ == '__main__':
    url = "http://47.108.206.100:8085"
    payload1 = {
        "username": "Jerry5",
        "password": "123456789"}
    headers = Memberlnterface(url).get_member_token(payload1)
    payload = {
        "city": "华夏",
        "defaultStatus": 0,
        "detailAddress": "烤猪大学",
        "id": 0,
        "memberId": 1828,
        "name": "亚索",
        "phoneNumber": "13160407442",
        "postCode": "42222",
        "province": "湖北省",
        "region": "洪山区"}
    address = AddressInrerface(url, headers)
    getress =address.address(payload)
    print(getress)
    print(address.get_ress(2460))







